
/*************************************************************
This is the function that makes the decision to which IMF 
you should use and set a pointer to that function as a global variable

Written by MF&RD, Apr 2010
**************************************************************/

extern double (*imf)(gsl_rng *);


void imf_initialise(string imf_type){

  
  int set=0;
  
  cout<<"IMF_INIT: Initialise IMF to "<<imf_type<<endl;

  //go for a kroupa IMF (the ==0 is corrrect!!!)
  if (imf_type.compare("KROUPA") == 0) {
    imf = &kroupa_imf;
    set=1;
  }
  if (imf_type.compare("SALPETER") == 0) {
    imf = &salpeter_imf;
    set=1;
  }
 
  if (imf_type.compare("CHABRIER") == 0) {
    imf = &chabrier_imf;
    set=1;
  }
 
 if (imf_type.compare("IGIMF") == 0) {
    imf = &igimf_imf;
    set=1;
  }

 if (imf_type.compare("SLOPE") == 0) {
    imf = &slope_imf;
    set=1;
  }
  
  //return error if initilization fails
  if(set == 0){
    cout<<"IMF_IMIT: Unable to set the IMF function!!!"<<endl;
    exit(3);
  }
  
  return;

}
